package cn.com.scan.tools;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by My on 2016/1/1.
 */
public class SharedPreferencesUtils {
    public static String  getIP(Context context){
        SharedPreferences sp=context.getSharedPreferences("Scan", Context.MODE_PRIVATE);
        String  ip=sp.getString("IP","127.0.0.1:80");
        return ip;
    }
    public static void   setIP(Context context,String  ip){
        SharedPreferences.Editor ed=context.getSharedPreferences("Scan", Context.MODE_PRIVATE).edit();
        ed.putString("IP",ip);
        ed.commit();
    }
    //存储用户信息
    public static  void  setUserInfo(Context context,String  userStr){
        SharedPreferences.Editor ed=context.getSharedPreferences("Scan", Context.MODE_PRIVATE).edit();
        ed.putString("user",userStr);
        ed.commit();
    }
    //获取用户信息
    public static String  getUserInfo(Context context){
        SharedPreferences sp=context.getSharedPreferences("Scan", Context.MODE_PRIVATE);
        String  user=sp.getString("user","");
        return user;
    }
    //存储用户选择的库房
    public static  void  setUserStorage(Context context,String  storage){
        SharedPreferences.Editor ed=context.getSharedPreferences("Scan", Context.MODE_PRIVATE).edit();
        ed.putString("storage",storage);
        ed.commit();
    }
    //获取用户选择的病房
    public static String  getUserStorage(Context context){
        SharedPreferences sp=context.getSharedPreferences("Scan", Context.MODE_PRIVATE);
        String  storage=sp.getString("storage","");
        return storage;
    }
}
